package simple;
import java.util.Scanner;


public class SecuredNotepad extends SimpleNotepad  {
	private String password;
	private Scanner input = new Scanner(System.in);
	
	public SecuredNotepad(String password) {
		if ( password != null ) {
			this.password = password;
		}
		else {
			this.password = "";
		}
	}
	
	
	@Override
	public void addTextToPage(int pageNumber, String text) {
		if ( getPassword().equals(this.password) )
			super.addTextToPage(pageNumber, text);
		else
			System.out.println("Password did not match");
	}
	
	@Override
	public void removeText(int pageNumber) {
		if ( getPassword().equals(this.password) )
			super.removeText(pageNumber);
		else
			System.out.println("Password did not match");
	}

	private String getPassword() {
		System.out.println("Enter password since you are using secured notepad : ");
		return input.nextLine();
	}
}